<template>
	<view class="container">
		<NavBar :isBack="false">
			<view class="signIn">
				<text class="iconfont icon-qiandao" @click="gotoGuardPage('/subcom-my/Sign/Sign')"></text>
			</view>
		</NavBar>
		<MyUser></MyUser>
		<view class="myAbout">
			<view
				class="item"
				v-for="(item,index) of list"
				:key="item.name"
				@click="gotoGuardPage(item.routePath)"
			>
				<text class="tip">{{item.name}}</text>
				<text class="iconfont icon-qianjin"></text>
			</view>
			<u-button v-if="logoutBtn" text="退出帐号" shape="circle" type="success" size="normal" @click="logout"></u-button>
		</view>
	</view>
</template>

<script>
import NavBar from '@/components/NavBar/NavBar'
import MyUser from './components/My-User.vue'
import { gotoGuard, checkAuth } from '@/common/checkAuth'
export default {
  components: {
    NavBar,
    MyUser
  },
  data () {
    return {
      list: [
        {
          name: '我的收货地址',
          routePath: '/subcom-my/Address/Address'
        },
        {
          name: '我的发帖',
          routePath: '/subcom-my/MyPost/MyPost'
        },
        {
          name: '我的订单',
          routePath: '/subcom-my/MyOrder/MyOrder'
        },
        {
          name: '领劵中心',
          routePath: '/subcom-my/Coupon/Coupon'
        },
        {
          name: '我的优惠券',
          routePath: '/subcom-my/MyCoupon/MyCoupon'
        },
        {
          name: '充值',
          routePath: '/subcom-my/Recharge/Recharge'
        },
      ],
      logoutBtn: false
    }
  },
  onShow () {
    this.logoutBtn = checkAuth()
  },
  methods: {
    gotoGuardPage (path) {
      gotoGuard(path)
    },
    logout () {
      const this_ = this
      uni.showModal({
        title: '提示',
        content: '您确定要退出登录吗？',
        success: function (res) {
          if (res.confirm) {
            this_.$store.dispatch('logout')
            this_.logoutBtn = checkAuth()
          }
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
/* #ifndef APP-NVUE */
::v-deep .u-image{
			width: 180rpx;
			height: 180rpx;
			display: flex;
			justify-content: center;
			align-items: center;
		}
/* #endif */
.container {
	width: 100%;
	height: 100%;
	display: flex;
	flex-direction: column;
  .signIn {
    width: 240rpx;
    height: 100%;
    position: absolute;
    left: 20rpx;
    top: 0;
    display: flex;
	justify-content: space-between;
    align-items: center;
    .icon-qiandao {
      font-size: 70rpx;
      color: rgb(203, 235, 224);
      text-shadow: 2rpx 2rpx 4rpx rgb(15, 65, 49);
    }
  }
  .myAbout {
	flex: 1;
    padding: 10rpx;
    background-color: rgb(240, 240, 240);
    .item {
      width: 100%;
      height: 100rpx;
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-radius: 20rpx;
      background-color: #fff;
      margin-bottom: 20rpx;
      padding: 0 20rpx;
      box-sizing: border-box;
	  .tip{
		  font-size: 28rpx;
	  }
    }
  }
}
</style>
